#ifndef NDLOGIN_H
#define NDLOGIN_H

#include <QObject>
#include <QtNetwork>

class NDLogin : public QObject
{
	Q_OBJECT

public:

	static const QString HOST;
	static const QString LOGIN_PAGE;
	static const QString TRANSACTIONS_PAGE;

	NDLogin(const QString& netID, QObject* parent = 0);

	void login(const QString& password);
	void getTransactions();

	const QString& netID() const;

private:
	QString m_netID;
	QString m_cookies;

	QHttp* m_http;

	int m_loginRequestId;
	int m_transactionsRequestId;
	int m_balancesRequestId;

	QList<QStringList> m_transactions;

private slots:
	void slot_requestFinished(int, bool);

signals:
	void loginSuccess(const QString&);
	void loginFailure();
	void gotTransactions(const QList<QStringList>&);
	void gotBalances(const double&, const double&);
	void httpError(const QString&);
};

#endif // NDLOGIN_H
